﻿namespace com.crownpack
{
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;

    using ReferenceFieldControl = CustomerFieldFieldControl;

    using ReferenceFieldValue = CustomerFieldValue;

    public class CustomerField : SPFieldMultiColumn
    {
        #region Constructors

        public CustomerField( SPFieldCollection fields, string fieldName )
            : base(fields, fieldName)
        {
        }

        public CustomerField( SPFieldCollection fields, string typeName, string displayName )
            : base(fields, typeName, displayName)
        {
        }

        #endregion Constructors

        #region Properties

        public override BaseFieldControl FieldRenderingControl
        {
            get
            {
                BaseFieldControl baseFieldControl = new ReferenceFieldControl( );
                baseFieldControl.FieldName = this.InternalName;
                return baseFieldControl;
            }
        }

        #endregion Properties

        #region Methods

        public override string GetFieldValueAsHtml( object value )
        {
            if ( value == null )
                return string.Empty;
            string v = value.ToString( );
            if ( string.IsNullOrEmpty( v ) )
                return string.Empty;
            SPFieldMultiColumnValue mcv = new SPFieldMultiColumnValue( v );
            ReferenceFieldValue o = new ReferenceFieldValue( mcv );
            string s = o.GetHtmlFormat( );
            return s;
        }

        #endregion Methods
    }
}